/*
 * @file    :task_comm.h
 * @author  :LingFengLu
 * @date    :2023-06-08
 */

#ifndef _TASK_COMM_H_
#define _TASK_COMM_H_
#include "aes_custom.h"
#include "global.h"
#include "devos.h"
#include "message.h"
//Constant definition    宏定义

#define TASK_COMM_MAX_ID_LENGTH             32
#define TASK_COMM_BOND_ID_LENGTH            6
#define TASK_COMM_BROADCAST_DATA_SIZE	    18
//Type definition    类型定义
typedef enum
{
    TASK_COMM_IDENTIFIER_ADDRESS = 0,//MAC Address
    TASK_COMM_IDENTIFIER_USER_ID,//
    TASK_COMM_COUNT_IDENTIFIER,
    TASK_COMM_IDENTIFIER_BOND_ID
} task_comm_identifier;

typedef enum
{
	TASK_COMM_PARAM_RF_STATE = 0,
	TASK_COMM_PARAM_RF_SIGNAL,
	TASK_COMM_PARAM_RF_LOCAL_ADDRESS,
	TASK_COMM_PARAM_RF_REMOTE_ADDRESS,
	TASK_COMM_PARAM_RF_BROADCAST_SWITCH,
	TASK_COMM_PARAM_BROADCAST_DATA,
	TASK_COMM_PARAM_BROADCAST_OFFSET,
	TASK_COMM_PARAM_ENABLE,
	TASK_COMM_PARAM_DISABLE,
	TASK_COMM_PARAM_BONDED,
	TASK_COMM_PARAM_BUSY,
	TASK_COMM_COUNT_PARAM
} task_comm_parameter;



typedef struct
{
	uint8 u8_Data[TASK_COMM_BROADCAST_DATA_SIZE];
	uint8 u8_RFSignal;
	uint8 u8_Checksum;
} task_comm_broadcast;

//Function declaration    函数申明
void TaskComm_Init
(
	devos_task_handle t_TaskHandle
);
void TaskComm_Process
(
	devos_task_handle t_TaskHandle
);
uint TaskComm_SetConfig
(
	uint ui_Parameter,
	const uint8 *u8p_Value,
	uint ui_Length
);
uint TaskComm_GetConfig
(
	uint ui_Parameter,
	uint8 *u8p_Value,
	uint *uip_Length
);

uint TaskComm_Pair
(
    uint ui_Parameter,
    uint8 *u8p_Value,
    uint *uip_Length
);
uint TaskComm_Unpair
(
    uint ui_Parameter,
    uint8 *u8p_Value,
    uint *uip_Length
);
uint TaskComm_Bond
(
    uint ui_Parameter,
    uint8 *u8p_Value,
    uint *uip_Length
);

uint TaskComm_Send
( 
    uint8 u8_Address,
    uint8 u8_SourcePort,
    uint8 u8_TargetPort,
    message_command *tp_Command,
    uint8 u8_Mode 
);

uint TaskComm_Receive
( 
    uint8 u8_Address,
    uint8 *u8p_SourcePort,
    uint8 *u8p_TargetPort,
    message_command *tp_Command,
    uint8 *u8p_Mode 
);
void TaskComm_ClearQueueMessage(void);
//Golbal variable declaration   全局变量申明










#endif

